{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "8e10aa18-cd11-42b0-bbdb-62ebf9b12a61",
   "metadata": {},
   "source": [
    "# Expanding Plot Limits with expandLimits()\n",
    "\n",
    "When creating visualizations, you might occasionally need to adjust your plot boundaries to encompass specific data points or values. This is where the `expandLimits()` function comes in handy. It allows you to extend the plot's scales to include particular values, ensuring they're visible in your visualization."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "32da89cf-d22c-4cd8-be22-3574e3d4356f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"yxClsh\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"library\">\n",
       "       if(!window.letsPlotCallQueue) {\n",
       "           window.letsPlotCallQueue = [];\n",
       "       }; \n",
       "       window.letsPlotCall = function(f) {\n",
       "           window.letsPlotCallQueue.push(f);\n",
       "       };\n",
       "       (function() {\n",
       "           var script = document.createElement(\"script\");\n",
       "           script.type = \"text/javascript\";\n",
       "           script.src = \"https://cdn.jsdelivr.net/gh/JetBrains/lets-plot@v4.5.1/js-package/distr/lets-plot.min.js\";\n",
       "           script.onload = function() {\n",
       "               window.letsPlotCall = function(f) {f();};\n",
       "               window.letsPlotCallQueue.forEach(function(f) {f();});\n",
       "               window.letsPlotCallQueue = [];\n",
       "               \n",
       "               \n",
       "           };\n",
       "           script.onerror = function(event) {\n",
       "               window.letsPlotCall = function(f) {};\n",
       "               window.letsPlotCallQueue = [];\n",
       "               var div = document.createElement(\"div\");\n",
       "               div.style.color = 'darkred';\n",
       "               div.textContent = 'Error loading Lets-Plot JS';\n",
       "               document.getElementById(\"yxClsh\").appendChild(div);\n",
       "           };\n",
       "           var e = document.getElementById(\"yxClsh\");\n",
       "           e.appendChild(script);\n",
       "       })();\n",
       "   </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "            <div id=\"kotlin_out_0\"></div>\n",
       "            <script type=\"text/javascript\">\n",
       "                            if(!window.kotlinQueues) {\n",
       "                window.kotlinQueues = {};\n",
       "            }\n",
       "            if(!window.kotlinQueues[\"DataFrame\"]) {\n",
       "                var resQueue = [];\n",
       "                window.kotlinQueues[\"DataFrame\"] = resQueue;\n",
       "                window[\"call_DataFrame\"] = function(f) {\n",
       "                    resQueue.push(f);\n",
       "                }\n",
       "            }\n",
       "            (function (){\n",
       "                var modifiers = [(function(script) {\n",
       "    script.src = \"https://cdn.jsdelivr.net/gh/Kotlin/dataframe@3db46ccccaa1291c0627307d64133317f545e6ae/core/src/main/resources/init.js\"\n",
       "    script.type = \"text/javascript\";\n",
       "})];\n",
       "                var e = document.getElementById(\"kotlin_out_0\");\n",
       "                modifiers.forEach(function (gen) {\n",
       "                    var script = document.createElement(\"script\");\n",
       "                    gen(script)\n",
       "                    script.addEventListener(\"load\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {f();};\n",
       "                        window.kotlinQueues[\"DataFrame\"].forEach(function(f) {f();});\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                    }, false);\n",
       "                    script.addEventListener(\"error\", function() {\n",
       "                        window[\"call_DataFrame\"] = function(f) {};\n",
       "                        window.kotlinQueues[\"DataFrame\"] = [];\n",
       "                        var div = document.createElement(\"div\");\n",
       "                        div.style.color = 'darkred';\n",
       "                        div.textContent = 'Error loading resource DataFrame';\n",
       "                        document.getElementById(\"kotlin_out_0\").appendChild(div);\n",
       "                    }, false);\n",
       "                    \n",
       "                    e.appendChild(script);\n",
       "                });\n",
       "            })();\n",
       "            </script>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "                <style>\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "                </style>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%useLatestDescriptors\n",
    "%use lets-plot\n",
    "%use dataframe"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "511dfc65-66c1-481a-a8c4-ae75ff5945b0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Lets-Plot Kotlin API v.4.9.0. Frontend: Notebook with dynamically loaded JS. Lets-Plot JS v.4.5.1."
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "LetsPlot.getInfo()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "266d5c9a-4204-4f9c-a08f-a55a3d2e9cef",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/kotlindataframe+json": "{\"nrow\":3,\"ncol\":9,\"columns\":[\"miles per gallon\",\"number of cylinders\",\"engine displacement (cu. inches)\",\"engine horsepower\",\"vehicle weight (lbs.)\",\"time to accelerate (sec.)\",\"model year\",\"origin of car\",\"vehicle name\"],\"kotlin_dataframe\":[{\"miles per gallon\":18.0,\"number of cylinders\":8,\"engine displacement (cu. inches)\":307.0,\"engine horsepower\":130,\"vehicle weight (lbs.)\":3504,\"time to accelerate (sec.)\":12.0,\"model year\":70,\"origin of car\":\"US\",\"vehicle name\":\"chevrolet chevelle malibu\"},{\"miles per gallon\":15.0,\"number of cylinders\":8,\"engine displacement (cu. inches)\":350.0,\"engine horsepower\":165,\"vehicle weight (lbs.)\":3693,\"time to accelerate (sec.)\":11.5,\"model year\":70,\"origin of car\":\"US\",\"vehicle name\":\"buick skylark 320\"},{\"miles per gallon\":18.0,\"number of cylinders\":8,\"engine displacement (cu. inches)\":318.0,\"engine horsepower\":150,\"vehicle weight (lbs.)\":3436,\"time to accelerate (sec.)\":11.0,\"model year\":70,\"origin of car\":\"US\",\"vehicle name\":\"plymouth satellite\"}]}",
      "text/html": [
       "        <html>\n",
       "        <head>\n",
       "            <style type=\"text/css\">\n",
       "                :root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       ":root {\n",
       "    --background: #fff;\n",
       "    --background-odd: #f5f5f5;\n",
       "    --background-hover: #d9edfd;\n",
       "    --header-text-color: #474747;\n",
       "    --text-color: #848484;\n",
       "    --text-color-dark: #000;\n",
       "    --text-color-medium: #737373;\n",
       "    --text-color-pale: #b3b3b3;\n",
       "    --inner-border-color: #aaa;\n",
       "    --bold-border-color: #000;\n",
       "    --link-color: #296eaa;\n",
       "    --link-color-pale: #296eaa;\n",
       "    --link-hover: #1a466c;\n",
       "}\n",
       "\n",
       ":root[theme=\"dark\"], :root [data-jp-theme-light=\"false\"], .dataframe_dark{\n",
       "    --background: #303030;\n",
       "    --background-odd: #3c3c3c;\n",
       "    --background-hover: #464646;\n",
       "    --header-text-color: #dddddd;\n",
       "    --text-color: #b3b3b3;\n",
       "    --text-color-dark: #dddddd;\n",
       "    --text-color-medium: #b2b2b2;\n",
       "    --text-color-pale: #737373;\n",
       "    --inner-border-color: #707070;\n",
       "    --bold-border-color: #777777;\n",
       "    --link-color: #008dc0;\n",
       "    --link-color-pale: #97e1fb;\n",
       "    --link-hover: #00688e;\n",
       "}\n",
       "\n",
       "p.dataframe_description {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe {\n",
       "    font-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n",
       "    font-size: 12px;\n",
       "    background-color: var(--background);\n",
       "    color: var(--text-color-dark);\n",
       "    border: none;\n",
       "    border-collapse: collapse;\n",
       "}\n",
       "\n",
       "table.dataframe th, td {\n",
       "    padding: 6px;\n",
       "    border: 1px solid transparent;\n",
       "    text-align: left;\n",
       "}\n",
       "\n",
       "table.dataframe th {\n",
       "    background-color: var(--background);\n",
       "    color: var(--header-text-color);\n",
       "}\n",
       "\n",
       "table.dataframe td {\n",
       "    vertical-align: top;\n",
       "}\n",
       "\n",
       "table.dataframe th.bottomBorder {\n",
       "    border-bottom-color: var(--bold-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(odd) {\n",
       "    background: var(--background-odd);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:nth-child(even) {\n",
       "    background: var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe tbody > tr:hover {\n",
       "    background: var(--background-hover);\n",
       "}\n",
       "\n",
       "table.dataframe a {\n",
       "    cursor: pointer;\n",
       "    color: var(--link-color);\n",
       "    text-decoration: none;\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover > td a {\n",
       "    color: var(--link-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe a:hover {\n",
       "    color: var(--link-hover);\n",
       "    text-decoration: underline;\n",
       "}\n",
       "\n",
       "table.dataframe img {\n",
       "    max-width: fit-content;\n",
       "}\n",
       "\n",
       "table.dataframe th.complex {\n",
       "    background-color: var(--background);\n",
       "    border: 1px solid var(--background);\n",
       "}\n",
       "\n",
       "table.dataframe .leftBorder {\n",
       "    border-left-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightBorder {\n",
       "    border-right-color: var(--inner-border-color);\n",
       "}\n",
       "\n",
       "table.dataframe .rightAlign {\n",
       "    text-align: right;\n",
       "}\n",
       "\n",
       "table.dataframe .expanderSvg {\n",
       "    width: 8px;\n",
       "    height: 8px;\n",
       "    margin-right: 3px;\n",
       "}\n",
       "\n",
       "table.dataframe .expander {\n",
       "    display: flex;\n",
       "    align-items: center;\n",
       "}\n",
       "\n",
       "/* formatting */\n",
       "\n",
       "table.dataframe .null {\n",
       "    color: var(--text-color-pale);\n",
       "}\n",
       "\n",
       "table.dataframe .structural {\n",
       "    color: var(--text-color-medium);\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .dataFrameCaption {\n",
       "    font-weight: bold;\n",
       "}\n",
       "\n",
       "table.dataframe .numbers {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe td:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "table.dataframe tr:hover .formatted .structural, .null {\n",
       "    color: var(--text-color-dark);\n",
       "}\n",
       "\n",
       "\n",
       "            </style>\n",
       "        </head>\n",
       "        <body>\n",
       "            <table class=\"dataframe\" id=\"df_402653184\"></table>\n",
       "\n",
       "<p class=\"dataframe_description\">DataFrame: rowsCount = 3, columnsCount = 9</p>\n",
       "<table class=\"dataframe\" id=\"static_df_402653185\"><thead><tr><th class=\"bottomBorder\" style=\"text-align:left\">miles per gallon</th><th class=\"bottomBorder\" style=\"text-align:left\">number of cylinders</th><th class=\"bottomBorder\" style=\"text-align:left\">engine displacement (cu. inches)</th><th class=\"bottomBorder\" style=\"text-align:left\">engine horsepower</th><th class=\"bottomBorder\" style=\"text-align:left\">vehicle weight (lbs.)</th><th class=\"bottomBorder\" style=\"text-align:left\">time to accelerate (sec.)</th><th class=\"bottomBorder\" style=\"text-align:left\">model year</th><th class=\"bottomBorder\" style=\"text-align:left\">origin of car</th><th class=\"bottomBorder\" style=\"text-align:left\">vehicle name</th></tr></thead><tbody><tr><td  style=\"vertical-align:top\">18.000000</td><td  style=\"vertical-align:top\">8</td><td  style=\"vertical-align:top\">307.000000</td><td  style=\"vertical-align:top\">130</td><td  style=\"vertical-align:top\">3504</td><td  style=\"vertical-align:top\">12.000000</td><td  style=\"vertical-align:top\">70</td><td  style=\"vertical-align:top\">US</td><td  style=\"vertical-align:top\">chevrolet chevelle malibu</td></tr><tr><td  style=\"vertical-align:top\">15.000000</td><td  style=\"vertical-align:top\">8</td><td  style=\"vertical-align:top\">350.000000</td><td  style=\"vertical-align:top\">165</td><td  style=\"vertical-align:top\">3693</td><td  style=\"vertical-align:top\">11.500000</td><td  style=\"vertical-align:top\">70</td><td  style=\"vertical-align:top\">US</td><td  style=\"vertical-align:top\">buick skylark 320</td></tr><tr><td  style=\"vertical-align:top\">18.000000</td><td  style=\"vertical-align:top\">8</td><td  style=\"vertical-align:top\">318.000000</td><td  style=\"vertical-align:top\">150</td><td  style=\"vertical-align:top\">3436</td><td  style=\"vertical-align:top\">11.000000</td><td  style=\"vertical-align:top\">70</td><td  style=\"vertical-align:top\">US</td><td  style=\"vertical-align:top\">plymouth satellite</td></tr></tbody></table>\n",
       "        </body>\n",
       "        <script>\n",
       "            /*<!--*/\n",
       "call_DataFrame(function() { DataFrame.addTable({ cols: [{ name: \"<span title=\\\"miles per gallon: Double\\\">miles per gallon</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">18.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">15.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">18.0</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"number of cylinders: Int\\\">number of cylinders</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">8</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">8</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">8</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"engine displacement (cu. inches): Double\\\">engine displacement (cu. inches)</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">307.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">350.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">318.0</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"engine horsepower: Int\\\">engine horsepower</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">130</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">165</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">150</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"vehicle weight (lbs.): Int\\\">vehicle weight (lbs.)</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3504</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3693</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">3436</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"time to accelerate (sec.): Double\\\">time to accelerate (sec.)</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">12.0</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">11.5</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">11.0</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"model year: Int\\\">model year</span>\", children: [], rightAlign: true, values: [\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">70</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">70</span></span>\",\"<span class=\\\"formatted\\\" title=\\\"\\\"><span class=\\\"numbers\\\">70</span></span>\"] }, \n",
       "{ name: \"<span title=\\\"origin of car: String\\\">origin of car</span>\", children: [], rightAlign: false, values: [\"US\",\"US\",\"US\"] }, \n",
       "{ name: \"<span title=\\\"vehicle name: String\\\">vehicle name</span>\", children: [], rightAlign: false, values: [\"chevrolet chevelle malibu\",\"buick skylark 320\",\"plymouth satellite\"] }, \n",
       "], id: 402653184, rootId: 402653184, totalRows: 3 } ) });\n",
       "/*-->*/\n",
       "\n",
       "call_DataFrame(function() { DataFrame.renderTable(402653184) });\n",
       "\n",
       "document.getElementById(\"static_df_402653185\").style.display = \"none\";\n",
       "        </script>\n",
       "        </html>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val mpg = DataFrame.readCSV(\"https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg2.csv\")\n",
    "mpg.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a9dda3b6-bbeb-4b9f-8f6f-f671c321f8c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"wIglNn\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   var containerDiv = document.getElementById(\"wIglNn\");\n",
       "   var observer = new ResizeObserver(function(entries) {\n",
       "       for (let entry of entries) {\n",
       "           var width = containerDiv.clientWidth\n",
       "           if (entry.contentBoxSize && width > 0) {\n",
       "           \n",
       "               // Render plot\n",
       "               if (observer) {\n",
       "                   observer.disconnect();\n",
       "                   observer = null;\n",
       "               }\n",
       "\n",
       "               var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"miles per gallon\",\n",
       "\"y\":\"vehicle weight (lbs.)\"\n",
       "},\n",
       "\"data\":{\n",
       "\"miles per gallon\":[18.0,15.0,18.0,16.0,17.0,15.0,14.0,14.0,14.0,15.0,15.0,14.0,15.0,14.0,24.0,22.0,18.0,21.0,27.0,26.0,25.0,24.0,25.0,26.0,21.0,10.0,10.0,11.0,9.0,27.0,28.0,25.0,19.0,16.0,17.0,19.0,18.0,14.0,14.0,14.0,14.0,12.0,13.0,13.0,18.0,22.0,19.0,18.0,23.0,28.0,30.0,30.0,31.0,35.0,27.0,26.0,24.0,25.0,23.0,20.0,21.0,13.0,14.0,15.0,14.0,17.0,11.0,13.0,12.0,13.0,19.0,15.0,13.0,13.0,14.0,18.0,22.0,21.0,26.0,22.0,28.0,23.0,28.0,27.0,13.0,14.0,13.0,14.0,15.0,12.0,13.0,13.0,14.0,13.0,12.0,13.0,18.0,16.0,18.0,18.0,23.0,26.0,11.0,12.0,13.0,12.0,18.0,20.0,21.0,22.0,18.0,19.0,21.0,26.0,15.0,16.0,29.0,24.0,20.0,19.0,15.0,24.0,20.0,11.0,20.0,19.0,15.0,31.0,26.0,32.0,25.0,16.0,16.0,18.0,16.0,13.0,14.0,14.0,14.0,29.0,26.0,26.0,31.0,32.0,28.0,24.0,26.0,24.0,26.0,31.0,19.0,18.0,15.0,15.0,16.0,15.0,16.0,14.0,17.0,16.0,15.0,18.0,21.0,20.0,13.0,29.0,23.0,20.0,23.0,24.0,25.0,24.0,18.0,29.0,19.0,23.0,23.0,22.0,25.0,33.0,28.0,25.0,25.0,26.0,27.0,17.5,16.0,15.5,14.5,22.0,22.0,24.0,22.5,29.0,24.5,29.0,33.0,20.0,18.0,18.5,17.5,29.5,32.0,28.0,26.5,20.0,13.0,19.0,19.0,16.5,16.5,13.0,13.0,13.0,31.5,30.0,36.0,25.5,33.5,17.5,17.0,15.5,15.0,17.5,20.5,19.0,18.5,16.0,15.5,15.5,16.0,29.0,24.5,26.0,25.5,30.5,33.5,30.0,30.5,22.0,21.5,21.5,43.1,36.1,32.8,39.4,36.1,19.9,19.4,20.2,19.2,20.5,20.2,25.1,20.5,19.4,20.6,20.8,18.6,18.1,19.2,17.7,18.1,17.5,30.0,27.5,27.2,30.9,21.1,23.2,23.8,23.9,20.3,17.0,21.6,16.2,31.5,29.5,21.5,19.8,22.3,20.2,20.6,17.0,17.6,16.5,18.2,16.9,15.5,19.2,18.5,31.9,34.1,35.7,27.4,25.4,23.0,27.2,23.9,34.2,34.5,31.8,37.3,28.4,28.8,26.8,33.5,41.5,38.1,32.1,37.2,28.0,26.4,24.3,19.1,34.3,29.8,31.3,37.0,32.2,46.6,27.9,40.8,44.3,43.4,36.4,30.0,44.6,33.8,29.8,32.7,23.7,35.0,32.4,27.2,26.6,25.8,23.5,30.0,39.1,39.0,35.1,32.3,37.0,37.7,34.1,34.7,34.4,29.9,33.0,33.7,32.4,32.9,31.6,28.1,30.7,25.4,24.2,22.4,26.6,20.2,17.6,28.0,27.0,34.0,31.0,29.0,27.0,24.0,36.0,37.0,31.0,38.0,36.0,36.0,36.0,34.0,38.0,32.0,38.0,25.0,38.0,26.0,22.0,32.0,36.0,27.0,27.0,44.0,32.0,28.0,31.0],\n",
       "\"vehicle weight (lbs.)\":[3504.0,3693.0,3436.0,3433.0,3449.0,4341.0,4354.0,4312.0,4425.0,3850.0,3563.0,3609.0,3761.0,3086.0,2372.0,2833.0,2774.0,2587.0,2130.0,1835.0,2672.0,2430.0,2375.0,2234.0,2648.0,4615.0,4376.0,4382.0,4732.0,2130.0,2264.0,2228.0,2634.0,3439.0,3329.0,3302.0,3288.0,4209.0,4464.0,4154.0,4096.0,4955.0,4746.0,5140.0,2962.0,2408.0,3282.0,3139.0,2220.0,2123.0,2074.0,2065.0,1773.0,1613.0,1834.0,1955.0,2278.0,2126.0,2254.0,2408.0,2226.0,4274.0,4385.0,4135.0,4129.0,3672.0,4633.0,4502.0,4456.0,4422.0,2330.0,3892.0,4098.0,4294.0,4077.0,2933.0,2511.0,2979.0,2189.0,2395.0,2288.0,2506.0,2164.0,2100.0,4100.0,3672.0,3988.0,4042.0,3777.0,4952.0,4464.0,4363.0,4237.0,4735.0,4951.0,3821.0,3121.0,3278.0,2945.0,3021.0,2904.0,1950.0,4997.0,4906.0,4654.0,4499.0,2789.0,2279.0,2401.0,2379.0,2124.0,2310.0,2472.0,2265.0,4082.0,4278.0,1867.0,2158.0,2582.0,2868.0,3399.0,2660.0,2807.0,3664.0,3102.0,2901.0,3336.0,1950.0,2451.0,1836.0,2542.0,3781.0,3632.0,3613.0,4141.0,4699.0,4457.0,4638.0,4257.0,2219.0,1963.0,2300.0,1649.0,2003.0,2125.0,2108.0,2246.0,2489.0,2391.0,2000.0,3264.0,3459.0,3432.0,3158.0,4668.0,4440.0,4498.0,4657.0,3907.0,3897.0,3730.0,3785.0,3039.0,3221.0,3169.0,2171.0,2639.0,2914.0,2592.0,2702.0,2223.0,2545.0,2984.0,1937.0,3211.0,2694.0,2957.0,2945.0,2671.0,1795.0,2464.0,2220.0,2572.0,2255.0,2202.0,4215.0,4190.0,3962.0,4215.0,3233.0,3353.0,3012.0,3085.0,2035.0,2164.0,1937.0,1795.0,3651.0,3574.0,3645.0,3193.0,1825.0,1990.0,2155.0,2565.0,3150.0,3940.0,3270.0,2930.0,3820.0,4380.0,4055.0,3870.0,3755.0,2045.0,2155.0,1825.0,2300.0,1945.0,3880.0,4060.0,4140.0,4295.0,3520.0,3425.0,3630.0,3525.0,4220.0,4165.0,4325.0,4335.0,1940.0,2740.0,2265.0,2755.0,2051.0,2075.0,1985.0,2190.0,2815.0,2600.0,2720.0,1985.0,1800.0,1985.0,2070.0,1800.0,3365.0,3735.0,3570.0,3535.0,3155.0,2965.0,2720.0,3430.0,3210.0,3380.0,3070.0,3620.0,3410.0,3425.0,3445.0,3205.0,4080.0,2155.0,2560.0,2300.0,2230.0,2515.0,2745.0,2855.0,2405.0,2830.0,3140.0,2795.0,3410.0,1990.0,2135.0,3245.0,2990.0,2890.0,3265.0,3360.0,3840.0,3725.0,3955.0,3830.0,4360.0,4054.0,3605.0,3940.0,1925.0,1975.0,1915.0,2670.0,3530.0,3900.0,3190.0,3420.0,2200.0,2150.0,2020.0,2130.0,2670.0,2595.0,2700.0,2556.0,2144.0,1968.0,2120.0,2019.0,2678.0,2870.0,3003.0,3381.0,2188.0,2711.0,2542.0,2434.0,2265.0,2110.0,2800.0,2110.0,2085.0,2335.0,2950.0,3250.0,1850.0,2145.0,1845.0,2910.0,2420.0,2500.0,2290.0,2490.0,2635.0,2620.0,2725.0,2385.0,1755.0,1875.0,1760.0,2065.0,1975.0,2050.0,1985.0,2215.0,2045.0,2380.0,2190.0,2210.0,2350.0,2615.0,2635.0,3230.0,3160.0,2900.0,2930.0,3415.0,3725.0,3060.0,3465.0,2605.0,2640.0,2395.0,2575.0,2525.0,2735.0,2865.0,1980.0,2025.0,1970.0,2125.0,2125.0,2160.0,2205.0,2245.0,1965.0,1965.0,1995.0,2945.0,3015.0,2585.0,2835.0,2665.0,2370.0,2950.0,2790.0,2130.0,2295.0,2625.0,2720.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"miles per gallon\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"number of cylinders\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"engine displacement (cu. inches)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"engine horsepower\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"vehicle weight (lbs.)\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"time to accelerate (sec.)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"model year\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"origin of car\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"vehicle name\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"1\"\n",
       "};\n",
       "               window.letsPlotCall(function() {\n",
       "       \n",
       "               var toolbar = null;\n",
       "               var plotContainer = containerDiv;               \n",
       "               \n",
       "                   var options = {\n",
       "                       sizing: {\n",
       "                           width_mode: \"min\",\n",
       "                           height_mode: \"scaled\",\n",
       "                           width: width\n",
       "                       }\n",
       "                   };\n",
       "                   var fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer, options);\n",
       "                   if (toolbar) {\n",
       "                     toolbar.bind(fig);\n",
       "                   }\n",
       "               });\n",
       "               \n",
       "               break;\n",
       "           }\n",
       "       }\n",
       "   });\n",
       "   \n",
       "   observer.observe(containerDiv);\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val p = letsPlot(mpg.toMap()) { x = \"miles per gallon\"; y = \"vehicle weight (lbs.)\"} + geomPoint()   \n",
    "p"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5cd8672-591b-4926-b366-0d0da30b1dad",
   "metadata": {},
   "source": [
    "#### Expand Lower Limit Along the x-axis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b9219347-8474-41b8-ad60-8b9ccdb4f37d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"U9FmNf\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   var containerDiv = document.getElementById(\"U9FmNf\");\n",
       "   var observer = new ResizeObserver(function(entries) {\n",
       "       for (let entry of entries) {\n",
       "           var width = containerDiv.clientWidth\n",
       "           if (entry.contentBoxSize && width > 0) {\n",
       "           \n",
       "               // Render plot\n",
       "               if (observer) {\n",
       "                   observer.disconnect();\n",
       "                   observer = null;\n",
       "               }\n",
       "\n",
       "               var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"miles per gallon\",\n",
       "\"y\":\"vehicle weight (lbs.)\"\n",
       "},\n",
       "\"data\":{\n",
       "\"miles per gallon\":[18.0,15.0,18.0,16.0,17.0,15.0,14.0,14.0,14.0,15.0,15.0,14.0,15.0,14.0,24.0,22.0,18.0,21.0,27.0,26.0,25.0,24.0,25.0,26.0,21.0,10.0,10.0,11.0,9.0,27.0,28.0,25.0,19.0,16.0,17.0,19.0,18.0,14.0,14.0,14.0,14.0,12.0,13.0,13.0,18.0,22.0,19.0,18.0,23.0,28.0,30.0,30.0,31.0,35.0,27.0,26.0,24.0,25.0,23.0,20.0,21.0,13.0,14.0,15.0,14.0,17.0,11.0,13.0,12.0,13.0,19.0,15.0,13.0,13.0,14.0,18.0,22.0,21.0,26.0,22.0,28.0,23.0,28.0,27.0,13.0,14.0,13.0,14.0,15.0,12.0,13.0,13.0,14.0,13.0,12.0,13.0,18.0,16.0,18.0,18.0,23.0,26.0,11.0,12.0,13.0,12.0,18.0,20.0,21.0,22.0,18.0,19.0,21.0,26.0,15.0,16.0,29.0,24.0,20.0,19.0,15.0,24.0,20.0,11.0,20.0,19.0,15.0,31.0,26.0,32.0,25.0,16.0,16.0,18.0,16.0,13.0,14.0,14.0,14.0,29.0,26.0,26.0,31.0,32.0,28.0,24.0,26.0,24.0,26.0,31.0,19.0,18.0,15.0,15.0,16.0,15.0,16.0,14.0,17.0,16.0,15.0,18.0,21.0,20.0,13.0,29.0,23.0,20.0,23.0,24.0,25.0,24.0,18.0,29.0,19.0,23.0,23.0,22.0,25.0,33.0,28.0,25.0,25.0,26.0,27.0,17.5,16.0,15.5,14.5,22.0,22.0,24.0,22.5,29.0,24.5,29.0,33.0,20.0,18.0,18.5,17.5,29.5,32.0,28.0,26.5,20.0,13.0,19.0,19.0,16.5,16.5,13.0,13.0,13.0,31.5,30.0,36.0,25.5,33.5,17.5,17.0,15.5,15.0,17.5,20.5,19.0,18.5,16.0,15.5,15.5,16.0,29.0,24.5,26.0,25.5,30.5,33.5,30.0,30.5,22.0,21.5,21.5,43.1,36.1,32.8,39.4,36.1,19.9,19.4,20.2,19.2,20.5,20.2,25.1,20.5,19.4,20.6,20.8,18.6,18.1,19.2,17.7,18.1,17.5,30.0,27.5,27.2,30.9,21.1,23.2,23.8,23.9,20.3,17.0,21.6,16.2,31.5,29.5,21.5,19.8,22.3,20.2,20.6,17.0,17.6,16.5,18.2,16.9,15.5,19.2,18.5,31.9,34.1,35.7,27.4,25.4,23.0,27.2,23.9,34.2,34.5,31.8,37.3,28.4,28.8,26.8,33.5,41.5,38.1,32.1,37.2,28.0,26.4,24.3,19.1,34.3,29.8,31.3,37.0,32.2,46.6,27.9,40.8,44.3,43.4,36.4,30.0,44.6,33.8,29.8,32.7,23.7,35.0,32.4,27.2,26.6,25.8,23.5,30.0,39.1,39.0,35.1,32.3,37.0,37.7,34.1,34.7,34.4,29.9,33.0,33.7,32.4,32.9,31.6,28.1,30.7,25.4,24.2,22.4,26.6,20.2,17.6,28.0,27.0,34.0,31.0,29.0,27.0,24.0,36.0,37.0,31.0,38.0,36.0,36.0,36.0,34.0,38.0,32.0,38.0,25.0,38.0,26.0,22.0,32.0,36.0,27.0,27.0,44.0,32.0,28.0,31.0],\n",
       "\"vehicle weight (lbs.)\":[3504.0,3693.0,3436.0,3433.0,3449.0,4341.0,4354.0,4312.0,4425.0,3850.0,3563.0,3609.0,3761.0,3086.0,2372.0,2833.0,2774.0,2587.0,2130.0,1835.0,2672.0,2430.0,2375.0,2234.0,2648.0,4615.0,4376.0,4382.0,4732.0,2130.0,2264.0,2228.0,2634.0,3439.0,3329.0,3302.0,3288.0,4209.0,4464.0,4154.0,4096.0,4955.0,4746.0,5140.0,2962.0,2408.0,3282.0,3139.0,2220.0,2123.0,2074.0,2065.0,1773.0,1613.0,1834.0,1955.0,2278.0,2126.0,2254.0,2408.0,2226.0,4274.0,4385.0,4135.0,4129.0,3672.0,4633.0,4502.0,4456.0,4422.0,2330.0,3892.0,4098.0,4294.0,4077.0,2933.0,2511.0,2979.0,2189.0,2395.0,2288.0,2506.0,2164.0,2100.0,4100.0,3672.0,3988.0,4042.0,3777.0,4952.0,4464.0,4363.0,4237.0,4735.0,4951.0,3821.0,3121.0,3278.0,2945.0,3021.0,2904.0,1950.0,4997.0,4906.0,4654.0,4499.0,2789.0,2279.0,2401.0,2379.0,2124.0,2310.0,2472.0,2265.0,4082.0,4278.0,1867.0,2158.0,2582.0,2868.0,3399.0,2660.0,2807.0,3664.0,3102.0,2901.0,3336.0,1950.0,2451.0,1836.0,2542.0,3781.0,3632.0,3613.0,4141.0,4699.0,4457.0,4638.0,4257.0,2219.0,1963.0,2300.0,1649.0,2003.0,2125.0,2108.0,2246.0,2489.0,2391.0,2000.0,3264.0,3459.0,3432.0,3158.0,4668.0,4440.0,4498.0,4657.0,3907.0,3897.0,3730.0,3785.0,3039.0,3221.0,3169.0,2171.0,2639.0,2914.0,2592.0,2702.0,2223.0,2545.0,2984.0,1937.0,3211.0,2694.0,2957.0,2945.0,2671.0,1795.0,2464.0,2220.0,2572.0,2255.0,2202.0,4215.0,4190.0,3962.0,4215.0,3233.0,3353.0,3012.0,3085.0,2035.0,2164.0,1937.0,1795.0,3651.0,3574.0,3645.0,3193.0,1825.0,1990.0,2155.0,2565.0,3150.0,3940.0,3270.0,2930.0,3820.0,4380.0,4055.0,3870.0,3755.0,2045.0,2155.0,1825.0,2300.0,1945.0,3880.0,4060.0,4140.0,4295.0,3520.0,3425.0,3630.0,3525.0,4220.0,4165.0,4325.0,4335.0,1940.0,2740.0,2265.0,2755.0,2051.0,2075.0,1985.0,2190.0,2815.0,2600.0,2720.0,1985.0,1800.0,1985.0,2070.0,1800.0,3365.0,3735.0,3570.0,3535.0,3155.0,2965.0,2720.0,3430.0,3210.0,3380.0,3070.0,3620.0,3410.0,3425.0,3445.0,3205.0,4080.0,2155.0,2560.0,2300.0,2230.0,2515.0,2745.0,2855.0,2405.0,2830.0,3140.0,2795.0,3410.0,1990.0,2135.0,3245.0,2990.0,2890.0,3265.0,3360.0,3840.0,3725.0,3955.0,3830.0,4360.0,4054.0,3605.0,3940.0,1925.0,1975.0,1915.0,2670.0,3530.0,3900.0,3190.0,3420.0,2200.0,2150.0,2020.0,2130.0,2670.0,2595.0,2700.0,2556.0,2144.0,1968.0,2120.0,2019.0,2678.0,2870.0,3003.0,3381.0,2188.0,2711.0,2542.0,2434.0,2265.0,2110.0,2800.0,2110.0,2085.0,2335.0,2950.0,3250.0,1850.0,2145.0,1845.0,2910.0,2420.0,2500.0,2290.0,2490.0,2635.0,2620.0,2725.0,2385.0,1755.0,1875.0,1760.0,2065.0,1975.0,2050.0,1985.0,2215.0,2045.0,2380.0,2190.0,2210.0,2350.0,2615.0,2635.0,3230.0,3160.0,2900.0,2930.0,3415.0,3725.0,3060.0,3465.0,2605.0,2640.0,2395.0,2575.0,2525.0,2735.0,2865.0,1980.0,2025.0,1970.0,2125.0,2125.0,2160.0,2205.0,2245.0,1965.0,1965.0,1995.0,2945.0,3015.0,2585.0,2835.0,2665.0,2370.0,2950.0,2790.0,2130.0,2295.0,2625.0,2720.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"inherit_aes\":false,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"blank\",\n",
       "\"data\":{\n",
       "\"x\":[0.0],\n",
       "\"y\":[null]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"miles per gallon\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"number of cylinders\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"engine displacement (cu. inches)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"engine horsepower\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"vehicle weight (lbs.)\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"time to accelerate (sec.)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"model year\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"origin of car\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"vehicle name\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"2\"\n",
       "};\n",
       "               window.letsPlotCall(function() {\n",
       "       \n",
       "               var toolbar = null;\n",
       "               var plotContainer = containerDiv;               \n",
       "               \n",
       "                   var options = {\n",
       "                       sizing: {\n",
       "                           width_mode: \"min\",\n",
       "                           height_mode: \"scaled\",\n",
       "                           width: width\n",
       "                       }\n",
       "                   };\n",
       "                   var fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer, options);\n",
       "                   if (toolbar) {\n",
       "                     toolbar.bind(fig);\n",
       "                   }\n",
       "               });\n",
       "               \n",
       "               break;\n",
       "           }\n",
       "       }\n",
       "   });\n",
       "   \n",
       "   observer.observe(containerDiv);\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p + expandLimits(x = 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "981f9128-2f41-4686-a486-60fe3701989f",
   "metadata": {},
   "source": [
    "#### Expand Limits Along the y-axis"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "281370d4-1887-4035-a7b0-6b5f636fca15",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"Q9md3j\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   var containerDiv = document.getElementById(\"Q9md3j\");\n",
       "   var observer = new ResizeObserver(function(entries) {\n",
       "       for (let entry of entries) {\n",
       "           var width = containerDiv.clientWidth\n",
       "           if (entry.contentBoxSize && width > 0) {\n",
       "           \n",
       "               // Render plot\n",
       "               if (observer) {\n",
       "                   observer.disconnect();\n",
       "                   observer = null;\n",
       "               }\n",
       "\n",
       "               var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"miles per gallon\",\n",
       "\"y\":\"vehicle weight (lbs.)\"\n",
       "},\n",
       "\"data\":{\n",
       "\"miles per gallon\":[18.0,15.0,18.0,16.0,17.0,15.0,14.0,14.0,14.0,15.0,15.0,14.0,15.0,14.0,24.0,22.0,18.0,21.0,27.0,26.0,25.0,24.0,25.0,26.0,21.0,10.0,10.0,11.0,9.0,27.0,28.0,25.0,19.0,16.0,17.0,19.0,18.0,14.0,14.0,14.0,14.0,12.0,13.0,13.0,18.0,22.0,19.0,18.0,23.0,28.0,30.0,30.0,31.0,35.0,27.0,26.0,24.0,25.0,23.0,20.0,21.0,13.0,14.0,15.0,14.0,17.0,11.0,13.0,12.0,13.0,19.0,15.0,13.0,13.0,14.0,18.0,22.0,21.0,26.0,22.0,28.0,23.0,28.0,27.0,13.0,14.0,13.0,14.0,15.0,12.0,13.0,13.0,14.0,13.0,12.0,13.0,18.0,16.0,18.0,18.0,23.0,26.0,11.0,12.0,13.0,12.0,18.0,20.0,21.0,22.0,18.0,19.0,21.0,26.0,15.0,16.0,29.0,24.0,20.0,19.0,15.0,24.0,20.0,11.0,20.0,19.0,15.0,31.0,26.0,32.0,25.0,16.0,16.0,18.0,16.0,13.0,14.0,14.0,14.0,29.0,26.0,26.0,31.0,32.0,28.0,24.0,26.0,24.0,26.0,31.0,19.0,18.0,15.0,15.0,16.0,15.0,16.0,14.0,17.0,16.0,15.0,18.0,21.0,20.0,13.0,29.0,23.0,20.0,23.0,24.0,25.0,24.0,18.0,29.0,19.0,23.0,23.0,22.0,25.0,33.0,28.0,25.0,25.0,26.0,27.0,17.5,16.0,15.5,14.5,22.0,22.0,24.0,22.5,29.0,24.5,29.0,33.0,20.0,18.0,18.5,17.5,29.5,32.0,28.0,26.5,20.0,13.0,19.0,19.0,16.5,16.5,13.0,13.0,13.0,31.5,30.0,36.0,25.5,33.5,17.5,17.0,15.5,15.0,17.5,20.5,19.0,18.5,16.0,15.5,15.5,16.0,29.0,24.5,26.0,25.5,30.5,33.5,30.0,30.5,22.0,21.5,21.5,43.1,36.1,32.8,39.4,36.1,19.9,19.4,20.2,19.2,20.5,20.2,25.1,20.5,19.4,20.6,20.8,18.6,18.1,19.2,17.7,18.1,17.5,30.0,27.5,27.2,30.9,21.1,23.2,23.8,23.9,20.3,17.0,21.6,16.2,31.5,29.5,21.5,19.8,22.3,20.2,20.6,17.0,17.6,16.5,18.2,16.9,15.5,19.2,18.5,31.9,34.1,35.7,27.4,25.4,23.0,27.2,23.9,34.2,34.5,31.8,37.3,28.4,28.8,26.8,33.5,41.5,38.1,32.1,37.2,28.0,26.4,24.3,19.1,34.3,29.8,31.3,37.0,32.2,46.6,27.9,40.8,44.3,43.4,36.4,30.0,44.6,33.8,29.8,32.7,23.7,35.0,32.4,27.2,26.6,25.8,23.5,30.0,39.1,39.0,35.1,32.3,37.0,37.7,34.1,34.7,34.4,29.9,33.0,33.7,32.4,32.9,31.6,28.1,30.7,25.4,24.2,22.4,26.6,20.2,17.6,28.0,27.0,34.0,31.0,29.0,27.0,24.0,36.0,37.0,31.0,38.0,36.0,36.0,36.0,34.0,38.0,32.0,38.0,25.0,38.0,26.0,22.0,32.0,36.0,27.0,27.0,44.0,32.0,28.0,31.0],\n",
       "\"vehicle weight (lbs.)\":[3504.0,3693.0,3436.0,3433.0,3449.0,4341.0,4354.0,4312.0,4425.0,3850.0,3563.0,3609.0,3761.0,3086.0,2372.0,2833.0,2774.0,2587.0,2130.0,1835.0,2672.0,2430.0,2375.0,2234.0,2648.0,4615.0,4376.0,4382.0,4732.0,2130.0,2264.0,2228.0,2634.0,3439.0,3329.0,3302.0,3288.0,4209.0,4464.0,4154.0,4096.0,4955.0,4746.0,5140.0,2962.0,2408.0,3282.0,3139.0,2220.0,2123.0,2074.0,2065.0,1773.0,1613.0,1834.0,1955.0,2278.0,2126.0,2254.0,2408.0,2226.0,4274.0,4385.0,4135.0,4129.0,3672.0,4633.0,4502.0,4456.0,4422.0,2330.0,3892.0,4098.0,4294.0,4077.0,2933.0,2511.0,2979.0,2189.0,2395.0,2288.0,2506.0,2164.0,2100.0,4100.0,3672.0,3988.0,4042.0,3777.0,4952.0,4464.0,4363.0,4237.0,4735.0,4951.0,3821.0,3121.0,3278.0,2945.0,3021.0,2904.0,1950.0,4997.0,4906.0,4654.0,4499.0,2789.0,2279.0,2401.0,2379.0,2124.0,2310.0,2472.0,2265.0,4082.0,4278.0,1867.0,2158.0,2582.0,2868.0,3399.0,2660.0,2807.0,3664.0,3102.0,2901.0,3336.0,1950.0,2451.0,1836.0,2542.0,3781.0,3632.0,3613.0,4141.0,4699.0,4457.0,4638.0,4257.0,2219.0,1963.0,2300.0,1649.0,2003.0,2125.0,2108.0,2246.0,2489.0,2391.0,2000.0,3264.0,3459.0,3432.0,3158.0,4668.0,4440.0,4498.0,4657.0,3907.0,3897.0,3730.0,3785.0,3039.0,3221.0,3169.0,2171.0,2639.0,2914.0,2592.0,2702.0,2223.0,2545.0,2984.0,1937.0,3211.0,2694.0,2957.0,2945.0,2671.0,1795.0,2464.0,2220.0,2572.0,2255.0,2202.0,4215.0,4190.0,3962.0,4215.0,3233.0,3353.0,3012.0,3085.0,2035.0,2164.0,1937.0,1795.0,3651.0,3574.0,3645.0,3193.0,1825.0,1990.0,2155.0,2565.0,3150.0,3940.0,3270.0,2930.0,3820.0,4380.0,4055.0,3870.0,3755.0,2045.0,2155.0,1825.0,2300.0,1945.0,3880.0,4060.0,4140.0,4295.0,3520.0,3425.0,3630.0,3525.0,4220.0,4165.0,4325.0,4335.0,1940.0,2740.0,2265.0,2755.0,2051.0,2075.0,1985.0,2190.0,2815.0,2600.0,2720.0,1985.0,1800.0,1985.0,2070.0,1800.0,3365.0,3735.0,3570.0,3535.0,3155.0,2965.0,2720.0,3430.0,3210.0,3380.0,3070.0,3620.0,3410.0,3425.0,3445.0,3205.0,4080.0,2155.0,2560.0,2300.0,2230.0,2515.0,2745.0,2855.0,2405.0,2830.0,3140.0,2795.0,3410.0,1990.0,2135.0,3245.0,2990.0,2890.0,3265.0,3360.0,3840.0,3725.0,3955.0,3830.0,4360.0,4054.0,3605.0,3940.0,1925.0,1975.0,1915.0,2670.0,3530.0,3900.0,3190.0,3420.0,2200.0,2150.0,2020.0,2130.0,2670.0,2595.0,2700.0,2556.0,2144.0,1968.0,2120.0,2019.0,2678.0,2870.0,3003.0,3381.0,2188.0,2711.0,2542.0,2434.0,2265.0,2110.0,2800.0,2110.0,2085.0,2335.0,2950.0,3250.0,1850.0,2145.0,1845.0,2910.0,2420.0,2500.0,2290.0,2490.0,2635.0,2620.0,2725.0,2385.0,1755.0,1875.0,1760.0,2065.0,1975.0,2050.0,1985.0,2215.0,2045.0,2380.0,2190.0,2210.0,2350.0,2615.0,2635.0,3230.0,3160.0,2900.0,2930.0,3415.0,3725.0,3060.0,3465.0,2605.0,2640.0,2395.0,2575.0,2525.0,2735.0,2865.0,1980.0,2025.0,1970.0,2125.0,2125.0,2160.0,2205.0,2245.0,1965.0,1965.0,1995.0,2945.0,3015.0,2585.0,2835.0,2665.0,2370.0,2950.0,2790.0,2130.0,2295.0,2625.0,2720.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"inherit_aes\":false,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"blank\",\n",
       "\"data\":{\n",
       "\"x\":[null,null],\n",
       "\"y\":[1000.0,9000.0]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"miles per gallon\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"number of cylinders\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"engine displacement (cu. inches)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"engine horsepower\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"vehicle weight (lbs.)\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"time to accelerate (sec.)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"model year\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"origin of car\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"vehicle name\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"3\"\n",
       "};\n",
       "               window.letsPlotCall(function() {\n",
       "       \n",
       "               var toolbar = null;\n",
       "               var plotContainer = containerDiv;               \n",
       "               \n",
       "                   var options = {\n",
       "                       sizing: {\n",
       "                           width_mode: \"min\",\n",
       "                           height_mode: \"scaled\",\n",
       "                           width: width\n",
       "                       }\n",
       "                   };\n",
       "                   var fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer, options);\n",
       "                   if (toolbar) {\n",
       "                     toolbar.bind(fig);\n",
       "                   }\n",
       "               });\n",
       "               \n",
       "               break;\n",
       "           }\n",
       "       }\n",
       "   });\n",
       "   \n",
       "   observer.observe(containerDiv);\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p + expandLimits(y = listOf(1000, 9000))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e54877bf-2660-4f17-bbda-aa5f7c160ed3",
   "metadata": {},
   "source": [
    "#### Expand Lower Limits Along Both Axes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "1dec751c-13b5-4001-9b3b-4778f26bf325",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"knhkeL\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   var containerDiv = document.getElementById(\"knhkeL\");\n",
       "   var observer = new ResizeObserver(function(entries) {\n",
       "       for (let entry of entries) {\n",
       "           var width = containerDiv.clientWidth\n",
       "           if (entry.contentBoxSize && width > 0) {\n",
       "           \n",
       "               // Render plot\n",
       "               if (observer) {\n",
       "                   observer.disconnect();\n",
       "                   observer = null;\n",
       "               }\n",
       "\n",
       "               var plotSpec={\n",
       "\"mapping\":{\n",
       "\"x\":\"miles per gallon\",\n",
       "\"y\":\"vehicle weight (lbs.)\"\n",
       "},\n",
       "\"data\":{\n",
       "\"miles per gallon\":[18.0,15.0,18.0,16.0,17.0,15.0,14.0,14.0,14.0,15.0,15.0,14.0,15.0,14.0,24.0,22.0,18.0,21.0,27.0,26.0,25.0,24.0,25.0,26.0,21.0,10.0,10.0,11.0,9.0,27.0,28.0,25.0,19.0,16.0,17.0,19.0,18.0,14.0,14.0,14.0,14.0,12.0,13.0,13.0,18.0,22.0,19.0,18.0,23.0,28.0,30.0,30.0,31.0,35.0,27.0,26.0,24.0,25.0,23.0,20.0,21.0,13.0,14.0,15.0,14.0,17.0,11.0,13.0,12.0,13.0,19.0,15.0,13.0,13.0,14.0,18.0,22.0,21.0,26.0,22.0,28.0,23.0,28.0,27.0,13.0,14.0,13.0,14.0,15.0,12.0,13.0,13.0,14.0,13.0,12.0,13.0,18.0,16.0,18.0,18.0,23.0,26.0,11.0,12.0,13.0,12.0,18.0,20.0,21.0,22.0,18.0,19.0,21.0,26.0,15.0,16.0,29.0,24.0,20.0,19.0,15.0,24.0,20.0,11.0,20.0,19.0,15.0,31.0,26.0,32.0,25.0,16.0,16.0,18.0,16.0,13.0,14.0,14.0,14.0,29.0,26.0,26.0,31.0,32.0,28.0,24.0,26.0,24.0,26.0,31.0,19.0,18.0,15.0,15.0,16.0,15.0,16.0,14.0,17.0,16.0,15.0,18.0,21.0,20.0,13.0,29.0,23.0,20.0,23.0,24.0,25.0,24.0,18.0,29.0,19.0,23.0,23.0,22.0,25.0,33.0,28.0,25.0,25.0,26.0,27.0,17.5,16.0,15.5,14.5,22.0,22.0,24.0,22.5,29.0,24.5,29.0,33.0,20.0,18.0,18.5,17.5,29.5,32.0,28.0,26.5,20.0,13.0,19.0,19.0,16.5,16.5,13.0,13.0,13.0,31.5,30.0,36.0,25.5,33.5,17.5,17.0,15.5,15.0,17.5,20.5,19.0,18.5,16.0,15.5,15.5,16.0,29.0,24.5,26.0,25.5,30.5,33.5,30.0,30.5,22.0,21.5,21.5,43.1,36.1,32.8,39.4,36.1,19.9,19.4,20.2,19.2,20.5,20.2,25.1,20.5,19.4,20.6,20.8,18.6,18.1,19.2,17.7,18.1,17.5,30.0,27.5,27.2,30.9,21.1,23.2,23.8,23.9,20.3,17.0,21.6,16.2,31.5,29.5,21.5,19.8,22.3,20.2,20.6,17.0,17.6,16.5,18.2,16.9,15.5,19.2,18.5,31.9,34.1,35.7,27.4,25.4,23.0,27.2,23.9,34.2,34.5,31.8,37.3,28.4,28.8,26.8,33.5,41.5,38.1,32.1,37.2,28.0,26.4,24.3,19.1,34.3,29.8,31.3,37.0,32.2,46.6,27.9,40.8,44.3,43.4,36.4,30.0,44.6,33.8,29.8,32.7,23.7,35.0,32.4,27.2,26.6,25.8,23.5,30.0,39.1,39.0,35.1,32.3,37.0,37.7,34.1,34.7,34.4,29.9,33.0,33.7,32.4,32.9,31.6,28.1,30.7,25.4,24.2,22.4,26.6,20.2,17.6,28.0,27.0,34.0,31.0,29.0,27.0,24.0,36.0,37.0,31.0,38.0,36.0,36.0,36.0,34.0,38.0,32.0,38.0,25.0,38.0,26.0,22.0,32.0,36.0,27.0,27.0,44.0,32.0,28.0,31.0],\n",
       "\"vehicle weight (lbs.)\":[3504.0,3693.0,3436.0,3433.0,3449.0,4341.0,4354.0,4312.0,4425.0,3850.0,3563.0,3609.0,3761.0,3086.0,2372.0,2833.0,2774.0,2587.0,2130.0,1835.0,2672.0,2430.0,2375.0,2234.0,2648.0,4615.0,4376.0,4382.0,4732.0,2130.0,2264.0,2228.0,2634.0,3439.0,3329.0,3302.0,3288.0,4209.0,4464.0,4154.0,4096.0,4955.0,4746.0,5140.0,2962.0,2408.0,3282.0,3139.0,2220.0,2123.0,2074.0,2065.0,1773.0,1613.0,1834.0,1955.0,2278.0,2126.0,2254.0,2408.0,2226.0,4274.0,4385.0,4135.0,4129.0,3672.0,4633.0,4502.0,4456.0,4422.0,2330.0,3892.0,4098.0,4294.0,4077.0,2933.0,2511.0,2979.0,2189.0,2395.0,2288.0,2506.0,2164.0,2100.0,4100.0,3672.0,3988.0,4042.0,3777.0,4952.0,4464.0,4363.0,4237.0,4735.0,4951.0,3821.0,3121.0,3278.0,2945.0,3021.0,2904.0,1950.0,4997.0,4906.0,4654.0,4499.0,2789.0,2279.0,2401.0,2379.0,2124.0,2310.0,2472.0,2265.0,4082.0,4278.0,1867.0,2158.0,2582.0,2868.0,3399.0,2660.0,2807.0,3664.0,3102.0,2901.0,3336.0,1950.0,2451.0,1836.0,2542.0,3781.0,3632.0,3613.0,4141.0,4699.0,4457.0,4638.0,4257.0,2219.0,1963.0,2300.0,1649.0,2003.0,2125.0,2108.0,2246.0,2489.0,2391.0,2000.0,3264.0,3459.0,3432.0,3158.0,4668.0,4440.0,4498.0,4657.0,3907.0,3897.0,3730.0,3785.0,3039.0,3221.0,3169.0,2171.0,2639.0,2914.0,2592.0,2702.0,2223.0,2545.0,2984.0,1937.0,3211.0,2694.0,2957.0,2945.0,2671.0,1795.0,2464.0,2220.0,2572.0,2255.0,2202.0,4215.0,4190.0,3962.0,4215.0,3233.0,3353.0,3012.0,3085.0,2035.0,2164.0,1937.0,1795.0,3651.0,3574.0,3645.0,3193.0,1825.0,1990.0,2155.0,2565.0,3150.0,3940.0,3270.0,2930.0,3820.0,4380.0,4055.0,3870.0,3755.0,2045.0,2155.0,1825.0,2300.0,1945.0,3880.0,4060.0,4140.0,4295.0,3520.0,3425.0,3630.0,3525.0,4220.0,4165.0,4325.0,4335.0,1940.0,2740.0,2265.0,2755.0,2051.0,2075.0,1985.0,2190.0,2815.0,2600.0,2720.0,1985.0,1800.0,1985.0,2070.0,1800.0,3365.0,3735.0,3570.0,3535.0,3155.0,2965.0,2720.0,3430.0,3210.0,3380.0,3070.0,3620.0,3410.0,3425.0,3445.0,3205.0,4080.0,2155.0,2560.0,2300.0,2230.0,2515.0,2745.0,2855.0,2405.0,2830.0,3140.0,2795.0,3410.0,1990.0,2135.0,3245.0,2990.0,2890.0,3265.0,3360.0,3840.0,3725.0,3955.0,3830.0,4360.0,4054.0,3605.0,3940.0,1925.0,1975.0,1915.0,2670.0,3530.0,3900.0,3190.0,3420.0,2200.0,2150.0,2020.0,2130.0,2670.0,2595.0,2700.0,2556.0,2144.0,1968.0,2120.0,2019.0,2678.0,2870.0,3003.0,3381.0,2188.0,2711.0,2542.0,2434.0,2265.0,2110.0,2800.0,2110.0,2085.0,2335.0,2950.0,3250.0,1850.0,2145.0,1845.0,2910.0,2420.0,2500.0,2290.0,2490.0,2635.0,2620.0,2725.0,2385.0,1755.0,1875.0,1760.0,2065.0,1975.0,2050.0,1985.0,2215.0,2045.0,2380.0,2190.0,2210.0,2350.0,2615.0,2635.0,3230.0,3160.0,2900.0,2930.0,3415.0,3725.0,3060.0,3465.0,2605.0,2640.0,2395.0,2575.0,2525.0,2735.0,2865.0,1980.0,2025.0,1970.0,2125.0,2125.0,2160.0,2205.0,2245.0,1965.0,1965.0,1995.0,2945.0,3015.0,2585.0,2835.0,2665.0,2370.0,2950.0,2790.0,2130.0,2295.0,2625.0,2720.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"inherit_aes\":false,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"blank\",\n",
       "\"data\":{\n",
       "\"x\":[0.0],\n",
       "\"y\":[0.0]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"miles per gallon\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"number of cylinders\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"engine displacement (cu. inches)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"engine horsepower\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"vehicle weight (lbs.)\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"time to accelerate (sec.)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"model year\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"origin of car\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"vehicle name\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"4\"\n",
       "};\n",
       "               window.letsPlotCall(function() {\n",
       "       \n",
       "               var toolbar = null;\n",
       "               var plotContainer = containerDiv;               \n",
       "               \n",
       "                   var options = {\n",
       "                       sizing: {\n",
       "                           width_mode: \"min\",\n",
       "                           height_mode: \"scaled\",\n",
       "                           width: width\n",
       "                       }\n",
       "                   };\n",
       "                   var fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer, options);\n",
       "                   if (toolbar) {\n",
       "                     toolbar.bind(fig);\n",
       "                   }\n",
       "               });\n",
       "               \n",
       "               break;\n",
       "           }\n",
       "       }\n",
       "   });\n",
       "   \n",
       "   observer.observe(containerDiv);\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p + expandLimits(x = 0, y = 0)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1db0d463-9457-430d-9c77-2d8909474b05",
   "metadata": {},
   "source": [
    "#### Expanding Color-scale Limits"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "970b37b5-3e06-4e41-9ef0-92c273b2c395",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "   <div id=\"Z0Utnt\"></div>\n",
       "   <script type=\"text/javascript\" data-lets-plot-script=\"plot\">\n",
       "   \n",
       "   (function() {\n",
       "   // ----------\n",
       "   \n",
       "   var containerDiv = document.getElementById(\"Z0Utnt\");\n",
       "   var observer = new ResizeObserver(function(entries) {\n",
       "       for (let entry of entries) {\n",
       "           var width = containerDiv.clientWidth\n",
       "           if (entry.contentBoxSize && width > 0) {\n",
       "           \n",
       "               // Render plot\n",
       "               if (observer) {\n",
       "                   observer.disconnect();\n",
       "                   observer = null;\n",
       "               }\n",
       "\n",
       "               var plotSpec={\n",
       "\"layout\":{\n",
       "\"name\":\"grid\",\n",
       "\"ncol\":2,\n",
       "\"nrow\":1,\n",
       "\"fit\":true,\n",
       "\"align\":false\n",
       "},\n",
       "\"figures\":[{\n",
       "\"mapping\":{\n",
       "\"x\":\"miles per gallon\",\n",
       "\"y\":\"vehicle weight (lbs.)\",\n",
       "\"color\":\"number of cylinders\"\n",
       "},\n",
       "\"data\":{\n",
       "\"miles per gallon\":[18.0,15.0,18.0,16.0,17.0,15.0,14.0,14.0,14.0,15.0,15.0,14.0,15.0,14.0,24.0,22.0,18.0,21.0,27.0,26.0,25.0,24.0,25.0,26.0,21.0,10.0,10.0,11.0,9.0,27.0,28.0,25.0,19.0,16.0,17.0,19.0,18.0,14.0,14.0,14.0,14.0,12.0,13.0,13.0,18.0,22.0,19.0,18.0,23.0,28.0,30.0,30.0,31.0,35.0,27.0,26.0,24.0,25.0,23.0,20.0,21.0,13.0,14.0,15.0,14.0,17.0,11.0,13.0,12.0,13.0,19.0,15.0,13.0,13.0,14.0,18.0,22.0,21.0,26.0,22.0,28.0,23.0,28.0,27.0,13.0,14.0,13.0,14.0,15.0,12.0,13.0,13.0,14.0,13.0,12.0,13.0,18.0,16.0,18.0,18.0,23.0,26.0,11.0,12.0,13.0,12.0,18.0,20.0,21.0,22.0,18.0,19.0,21.0,26.0,15.0,16.0,29.0,24.0,20.0,19.0,15.0,24.0,20.0,11.0,20.0,19.0,15.0,31.0,26.0,32.0,25.0,16.0,16.0,18.0,16.0,13.0,14.0,14.0,14.0,29.0,26.0,26.0,31.0,32.0,28.0,24.0,26.0,24.0,26.0,31.0,19.0,18.0,15.0,15.0,16.0,15.0,16.0,14.0,17.0,16.0,15.0,18.0,21.0,20.0,13.0,29.0,23.0,20.0,23.0,24.0,25.0,24.0,18.0,29.0,19.0,23.0,23.0,22.0,25.0,33.0,28.0,25.0,25.0,26.0,27.0,17.5,16.0,15.5,14.5,22.0,22.0,24.0,22.5,29.0,24.5,29.0,33.0,20.0,18.0,18.5,17.5,29.5,32.0,28.0,26.5,20.0,13.0,19.0,19.0,16.5,16.5,13.0,13.0,13.0,31.5,30.0,36.0,25.5,33.5,17.5,17.0,15.5,15.0,17.5,20.5,19.0,18.5,16.0,15.5,15.5,16.0,29.0,24.5,26.0,25.5,30.5,33.5,30.0,30.5,22.0,21.5,21.5,43.1,36.1,32.8,39.4,36.1,19.9,19.4,20.2,19.2,20.5,20.2,25.1,20.5,19.4,20.6,20.8,18.6,18.1,19.2,17.7,18.1,17.5,30.0,27.5,27.2,30.9,21.1,23.2,23.8,23.9,20.3,17.0,21.6,16.2,31.5,29.5,21.5,19.8,22.3,20.2,20.6,17.0,17.6,16.5,18.2,16.9,15.5,19.2,18.5,31.9,34.1,35.7,27.4,25.4,23.0,27.2,23.9,34.2,34.5,31.8,37.3,28.4,28.8,26.8,33.5,41.5,38.1,32.1,37.2,28.0,26.4,24.3,19.1,34.3,29.8,31.3,37.0,32.2,46.6,27.9,40.8,44.3,43.4,36.4,30.0,44.6,33.8,29.8,32.7,23.7,35.0,32.4,27.2,26.6,25.8,23.5,30.0,39.1,39.0,35.1,32.3,37.0,37.7,34.1,34.7,34.4,29.9,33.0,33.7,32.4,32.9,31.6,28.1,30.7,25.4,24.2,22.4,26.6,20.2,17.6,28.0,27.0,34.0,31.0,29.0,27.0,24.0,36.0,37.0,31.0,38.0,36.0,36.0,36.0,34.0,38.0,32.0,38.0,25.0,38.0,26.0,22.0,32.0,36.0,27.0,27.0,44.0,32.0,28.0,31.0],\n",
       "\"vehicle weight (lbs.)\":[3504.0,3693.0,3436.0,3433.0,3449.0,4341.0,4354.0,4312.0,4425.0,3850.0,3563.0,3609.0,3761.0,3086.0,2372.0,2833.0,2774.0,2587.0,2130.0,1835.0,2672.0,2430.0,2375.0,2234.0,2648.0,4615.0,4376.0,4382.0,4732.0,2130.0,2264.0,2228.0,2634.0,3439.0,3329.0,3302.0,3288.0,4209.0,4464.0,4154.0,4096.0,4955.0,4746.0,5140.0,2962.0,2408.0,3282.0,3139.0,2220.0,2123.0,2074.0,2065.0,1773.0,1613.0,1834.0,1955.0,2278.0,2126.0,2254.0,2408.0,2226.0,4274.0,4385.0,4135.0,4129.0,3672.0,4633.0,4502.0,4456.0,4422.0,2330.0,3892.0,4098.0,4294.0,4077.0,2933.0,2511.0,2979.0,2189.0,2395.0,2288.0,2506.0,2164.0,2100.0,4100.0,3672.0,3988.0,4042.0,3777.0,4952.0,4464.0,4363.0,4237.0,4735.0,4951.0,3821.0,3121.0,3278.0,2945.0,3021.0,2904.0,1950.0,4997.0,4906.0,4654.0,4499.0,2789.0,2279.0,2401.0,2379.0,2124.0,2310.0,2472.0,2265.0,4082.0,4278.0,1867.0,2158.0,2582.0,2868.0,3399.0,2660.0,2807.0,3664.0,3102.0,2901.0,3336.0,1950.0,2451.0,1836.0,2542.0,3781.0,3632.0,3613.0,4141.0,4699.0,4457.0,4638.0,4257.0,2219.0,1963.0,2300.0,1649.0,2003.0,2125.0,2108.0,2246.0,2489.0,2391.0,2000.0,3264.0,3459.0,3432.0,3158.0,4668.0,4440.0,4498.0,4657.0,3907.0,3897.0,3730.0,3785.0,3039.0,3221.0,3169.0,2171.0,2639.0,2914.0,2592.0,2702.0,2223.0,2545.0,2984.0,1937.0,3211.0,2694.0,2957.0,2945.0,2671.0,1795.0,2464.0,2220.0,2572.0,2255.0,2202.0,4215.0,4190.0,3962.0,4215.0,3233.0,3353.0,3012.0,3085.0,2035.0,2164.0,1937.0,1795.0,3651.0,3574.0,3645.0,3193.0,1825.0,1990.0,2155.0,2565.0,3150.0,3940.0,3270.0,2930.0,3820.0,4380.0,4055.0,3870.0,3755.0,2045.0,2155.0,1825.0,2300.0,1945.0,3880.0,4060.0,4140.0,4295.0,3520.0,3425.0,3630.0,3525.0,4220.0,4165.0,4325.0,4335.0,1940.0,2740.0,2265.0,2755.0,2051.0,2075.0,1985.0,2190.0,2815.0,2600.0,2720.0,1985.0,1800.0,1985.0,2070.0,1800.0,3365.0,3735.0,3570.0,3535.0,3155.0,2965.0,2720.0,3430.0,3210.0,3380.0,3070.0,3620.0,3410.0,3425.0,3445.0,3205.0,4080.0,2155.0,2560.0,2300.0,2230.0,2515.0,2745.0,2855.0,2405.0,2830.0,3140.0,2795.0,3410.0,1990.0,2135.0,3245.0,2990.0,2890.0,3265.0,3360.0,3840.0,3725.0,3955.0,3830.0,4360.0,4054.0,3605.0,3940.0,1925.0,1975.0,1915.0,2670.0,3530.0,3900.0,3190.0,3420.0,2200.0,2150.0,2020.0,2130.0,2670.0,2595.0,2700.0,2556.0,2144.0,1968.0,2120.0,2019.0,2678.0,2870.0,3003.0,3381.0,2188.0,2711.0,2542.0,2434.0,2265.0,2110.0,2800.0,2110.0,2085.0,2335.0,2950.0,3250.0,1850.0,2145.0,1845.0,2910.0,2420.0,2500.0,2290.0,2490.0,2635.0,2620.0,2725.0,2385.0,1755.0,1875.0,1760.0,2065.0,1975.0,2050.0,1985.0,2215.0,2045.0,2380.0,2190.0,2210.0,2350.0,2615.0,2635.0,3230.0,3160.0,2900.0,2930.0,3415.0,3725.0,3060.0,3465.0,2605.0,2640.0,2395.0,2575.0,2525.0,2735.0,2865.0,1980.0,2025.0,1970.0,2125.0,2125.0,2160.0,2205.0,2245.0,1965.0,1965.0,1995.0,2945.0,3015.0,2585.0,2835.0,2665.0,2370.0,2950.0,2790.0,2130.0,2295.0,2625.0,2720.0],\n",
       "\"number of cylinders\":[8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,4.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,6.0,4.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,3.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,6.0,4.0,8.0,8.0,8.0,8.0,6.0,4.0,4.0,4.0,3.0,4.0,6.0,4.0,8.0,8.0,4.0,4.0,4.0,4.0,8.0,4.0,6.0,8.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,6.0,8.0,8.0,4.0,4.0,6.0,4.0,4.0,4.0,4.0,6.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,8.0,4.0,6.0,6.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,4.0,3.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,6.0,6.0,6.0,4.0,6.0,6.0,6.0,6.0,6.0,6.0,8.0,6.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0,6.0,4.0,6.0,4.0,4.0,6.0,6.0,4.0,6.0,6.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,5.0,8.0,4.0,8.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0,4.0,4.0,4.0,4.0,6.0,3.0,4.0,4.0,4.0,4.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,8.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"miles per gallon\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"number of cylinders\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"engine displacement (cu. inches)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"engine horsepower\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"vehicle weight (lbs.)\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"time to accelerate (sec.)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"model year\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"origin of car\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"vehicle name\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"5\"\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"x\":\"miles per gallon\",\n",
       "\"y\":\"vehicle weight (lbs.)\",\n",
       "\"color\":\"number of cylinders\"\n",
       "},\n",
       "\"data\":{\n",
       "\"miles per gallon\":[18.0,15.0,18.0,16.0,17.0,15.0,14.0,14.0,14.0,15.0,15.0,14.0,15.0,14.0,24.0,22.0,18.0,21.0,27.0,26.0,25.0,24.0,25.0,26.0,21.0,10.0,10.0,11.0,9.0,27.0,28.0,25.0,19.0,16.0,17.0,19.0,18.0,14.0,14.0,14.0,14.0,12.0,13.0,13.0,18.0,22.0,19.0,18.0,23.0,28.0,30.0,30.0,31.0,35.0,27.0,26.0,24.0,25.0,23.0,20.0,21.0,13.0,14.0,15.0,14.0,17.0,11.0,13.0,12.0,13.0,19.0,15.0,13.0,13.0,14.0,18.0,22.0,21.0,26.0,22.0,28.0,23.0,28.0,27.0,13.0,14.0,13.0,14.0,15.0,12.0,13.0,13.0,14.0,13.0,12.0,13.0,18.0,16.0,18.0,18.0,23.0,26.0,11.0,12.0,13.0,12.0,18.0,20.0,21.0,22.0,18.0,19.0,21.0,26.0,15.0,16.0,29.0,24.0,20.0,19.0,15.0,24.0,20.0,11.0,20.0,19.0,15.0,31.0,26.0,32.0,25.0,16.0,16.0,18.0,16.0,13.0,14.0,14.0,14.0,29.0,26.0,26.0,31.0,32.0,28.0,24.0,26.0,24.0,26.0,31.0,19.0,18.0,15.0,15.0,16.0,15.0,16.0,14.0,17.0,16.0,15.0,18.0,21.0,20.0,13.0,29.0,23.0,20.0,23.0,24.0,25.0,24.0,18.0,29.0,19.0,23.0,23.0,22.0,25.0,33.0,28.0,25.0,25.0,26.0,27.0,17.5,16.0,15.5,14.5,22.0,22.0,24.0,22.5,29.0,24.5,29.0,33.0,20.0,18.0,18.5,17.5,29.5,32.0,28.0,26.5,20.0,13.0,19.0,19.0,16.5,16.5,13.0,13.0,13.0,31.5,30.0,36.0,25.5,33.5,17.5,17.0,15.5,15.0,17.5,20.5,19.0,18.5,16.0,15.5,15.5,16.0,29.0,24.5,26.0,25.5,30.5,33.5,30.0,30.5,22.0,21.5,21.5,43.1,36.1,32.8,39.4,36.1,19.9,19.4,20.2,19.2,20.5,20.2,25.1,20.5,19.4,20.6,20.8,18.6,18.1,19.2,17.7,18.1,17.5,30.0,27.5,27.2,30.9,21.1,23.2,23.8,23.9,20.3,17.0,21.6,16.2,31.5,29.5,21.5,19.8,22.3,20.2,20.6,17.0,17.6,16.5,18.2,16.9,15.5,19.2,18.5,31.9,34.1,35.7,27.4,25.4,23.0,27.2,23.9,34.2,34.5,31.8,37.3,28.4,28.8,26.8,33.5,41.5,38.1,32.1,37.2,28.0,26.4,24.3,19.1,34.3,29.8,31.3,37.0,32.2,46.6,27.9,40.8,44.3,43.4,36.4,30.0,44.6,33.8,29.8,32.7,23.7,35.0,32.4,27.2,26.6,25.8,23.5,30.0,39.1,39.0,35.1,32.3,37.0,37.7,34.1,34.7,34.4,29.9,33.0,33.7,32.4,32.9,31.6,28.1,30.7,25.4,24.2,22.4,26.6,20.2,17.6,28.0,27.0,34.0,31.0,29.0,27.0,24.0,36.0,37.0,31.0,38.0,36.0,36.0,36.0,34.0,38.0,32.0,38.0,25.0,38.0,26.0,22.0,32.0,36.0,27.0,27.0,44.0,32.0,28.0,31.0],\n",
       "\"vehicle weight (lbs.)\":[3504.0,3693.0,3436.0,3433.0,3449.0,4341.0,4354.0,4312.0,4425.0,3850.0,3563.0,3609.0,3761.0,3086.0,2372.0,2833.0,2774.0,2587.0,2130.0,1835.0,2672.0,2430.0,2375.0,2234.0,2648.0,4615.0,4376.0,4382.0,4732.0,2130.0,2264.0,2228.0,2634.0,3439.0,3329.0,3302.0,3288.0,4209.0,4464.0,4154.0,4096.0,4955.0,4746.0,5140.0,2962.0,2408.0,3282.0,3139.0,2220.0,2123.0,2074.0,2065.0,1773.0,1613.0,1834.0,1955.0,2278.0,2126.0,2254.0,2408.0,2226.0,4274.0,4385.0,4135.0,4129.0,3672.0,4633.0,4502.0,4456.0,4422.0,2330.0,3892.0,4098.0,4294.0,4077.0,2933.0,2511.0,2979.0,2189.0,2395.0,2288.0,2506.0,2164.0,2100.0,4100.0,3672.0,3988.0,4042.0,3777.0,4952.0,4464.0,4363.0,4237.0,4735.0,4951.0,3821.0,3121.0,3278.0,2945.0,3021.0,2904.0,1950.0,4997.0,4906.0,4654.0,4499.0,2789.0,2279.0,2401.0,2379.0,2124.0,2310.0,2472.0,2265.0,4082.0,4278.0,1867.0,2158.0,2582.0,2868.0,3399.0,2660.0,2807.0,3664.0,3102.0,2901.0,3336.0,1950.0,2451.0,1836.0,2542.0,3781.0,3632.0,3613.0,4141.0,4699.0,4457.0,4638.0,4257.0,2219.0,1963.0,2300.0,1649.0,2003.0,2125.0,2108.0,2246.0,2489.0,2391.0,2000.0,3264.0,3459.0,3432.0,3158.0,4668.0,4440.0,4498.0,4657.0,3907.0,3897.0,3730.0,3785.0,3039.0,3221.0,3169.0,2171.0,2639.0,2914.0,2592.0,2702.0,2223.0,2545.0,2984.0,1937.0,3211.0,2694.0,2957.0,2945.0,2671.0,1795.0,2464.0,2220.0,2572.0,2255.0,2202.0,4215.0,4190.0,3962.0,4215.0,3233.0,3353.0,3012.0,3085.0,2035.0,2164.0,1937.0,1795.0,3651.0,3574.0,3645.0,3193.0,1825.0,1990.0,2155.0,2565.0,3150.0,3940.0,3270.0,2930.0,3820.0,4380.0,4055.0,3870.0,3755.0,2045.0,2155.0,1825.0,2300.0,1945.0,3880.0,4060.0,4140.0,4295.0,3520.0,3425.0,3630.0,3525.0,4220.0,4165.0,4325.0,4335.0,1940.0,2740.0,2265.0,2755.0,2051.0,2075.0,1985.0,2190.0,2815.0,2600.0,2720.0,1985.0,1800.0,1985.0,2070.0,1800.0,3365.0,3735.0,3570.0,3535.0,3155.0,2965.0,2720.0,3430.0,3210.0,3380.0,3070.0,3620.0,3410.0,3425.0,3445.0,3205.0,4080.0,2155.0,2560.0,2300.0,2230.0,2515.0,2745.0,2855.0,2405.0,2830.0,3140.0,2795.0,3410.0,1990.0,2135.0,3245.0,2990.0,2890.0,3265.0,3360.0,3840.0,3725.0,3955.0,3830.0,4360.0,4054.0,3605.0,3940.0,1925.0,1975.0,1915.0,2670.0,3530.0,3900.0,3190.0,3420.0,2200.0,2150.0,2020.0,2130.0,2670.0,2595.0,2700.0,2556.0,2144.0,1968.0,2120.0,2019.0,2678.0,2870.0,3003.0,3381.0,2188.0,2711.0,2542.0,2434.0,2265.0,2110.0,2800.0,2110.0,2085.0,2335.0,2950.0,3250.0,1850.0,2145.0,1845.0,2910.0,2420.0,2500.0,2290.0,2490.0,2635.0,2620.0,2725.0,2385.0,1755.0,1875.0,1760.0,2065.0,1975.0,2050.0,1985.0,2215.0,2045.0,2380.0,2190.0,2210.0,2350.0,2615.0,2635.0,3230.0,3160.0,2900.0,2930.0,3415.0,3725.0,3060.0,3465.0,2605.0,2640.0,2395.0,2575.0,2525.0,2735.0,2865.0,1980.0,2025.0,1970.0,2125.0,2125.0,2160.0,2205.0,2245.0,1965.0,1965.0,1995.0,2945.0,3015.0,2585.0,2835.0,2665.0,2370.0,2950.0,2790.0,2130.0,2295.0,2625.0,2720.0],\n",
       "\"number of cylinders\":[8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,4.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,6.0,4.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,3.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,6.0,4.0,8.0,8.0,8.0,8.0,6.0,4.0,4.0,4.0,3.0,4.0,6.0,4.0,8.0,8.0,4.0,4.0,4.0,4.0,8.0,4.0,6.0,8.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,6.0,8.0,8.0,4.0,4.0,6.0,4.0,4.0,4.0,4.0,6.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,8.0,4.0,6.0,6.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,8.0,6.0,6.0,6.0,6.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,4.0,3.0,4.0,4.0,4.0,4.0,4.0,8.0,8.0,8.0,6.0,6.0,6.0,4.0,6.0,6.0,6.0,6.0,6.0,6.0,8.0,6.0,8.0,8.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0,6.0,4.0,6.0,4.0,4.0,6.0,6.0,4.0,6.0,6.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,4.0,4.0,4.0,4.0,5.0,8.0,4.0,8.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,5.0,4.0,4.0,4.0,4.0,6.0,3.0,4.0,4.0,4.0,4.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,6.0,6.0,8.0,6.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.0,4.0,6.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0]\n",
       "},\n",
       "\"kind\":\"plot\",\n",
       "\"scales\":[],\n",
       "\"layers\":[{\n",
       "\"mapping\":{\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"point\",\n",
       "\"data\":{\n",
       "}\n",
       "},{\n",
       "\"mapping\":{\n",
       "\"x\":\"x\",\n",
       "\"y\":\"y\",\n",
       "\"color\":\"color\"\n",
       "},\n",
       "\"stat\":\"identity\",\n",
       "\"inherit_aes\":false,\n",
       "\"position\":\"identity\",\n",
       "\"geom\":\"blank\",\n",
       "\"data\":{\n",
       "\"color\":[2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],\n",
       "\"x\":[null,null,null,null,null,null,null,null,null],\n",
       "\"y\":[null,null,null,null,null,null,null,null,null]\n",
       "}\n",
       "}],\n",
       "\"data_meta\":{\n",
       "\"series_annotations\":[{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"miles per gallon\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"number of cylinders\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"engine displacement (cu. inches)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"engine horsepower\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"vehicle weight (lbs.)\"\n",
       "},{\n",
       "\"type\":\"float\",\n",
       "\"column\":\"time to accelerate (sec.)\"\n",
       "},{\n",
       "\"type\":\"int\",\n",
       "\"column\":\"model year\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"origin of car\"\n",
       "},{\n",
       "\"type\":\"str\",\n",
       "\"column\":\"vehicle name\"\n",
       "}]\n",
       "},\n",
       "\"spec_id\":\"6\"\n",
       "}],\n",
       "\"kind\":\"subplots\"\n",
       "};\n",
       "               window.letsPlotCall(function() {\n",
       "       \n",
       "               var toolbar = null;\n",
       "               var plotContainer = containerDiv;               \n",
       "               \n",
       "                   var options = {\n",
       "                       sizing: {\n",
       "                           width_mode: \"min\",\n",
       "                           height_mode: \"scaled\",\n",
       "                           width: width\n",
       "                       }\n",
       "                   };\n",
       "                   var fig = LetsPlot.buildPlotFromProcessedSpecs(plotSpec, -1, -1, plotContainer, options);\n",
       "                   if (toolbar) {\n",
       "                     toolbar.bind(fig);\n",
       "                   }\n",
       "               });\n",
       "               \n",
       "               break;\n",
       "           }\n",
       "       }\n",
       "   });\n",
       "   \n",
       "   observer.observe(containerDiv);\n",
       "   \n",
       "   // ----------\n",
       "   })();\n",
       "   \n",
       "   </script>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "// Same plot with color mapping\n",
    "val p1 = letsPlot(mpg.toMap()) { \n",
    "    x = \"miles per gallon\"\n",
    "    y = \"vehicle weight (lbs.)\"\n",
    "    color = \"number of cylinders\"\n",
    "} + geomPoint()   \n",
    "\n",
    "\n",
    "gggrid(listOf(\n",
    "    p1, \n",
    "    // Expand the color-scale limits.\n",
    "    p1 + expandLimits(color = 2..10)\n",
    "))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Kotlin",
   "language": "kotlin",
   "name": "kotlin"
  },
  "language_info": {
   "codemirror_mode": "text/x-kotlin",
   "file_extension": ".kt",
   "mimetype": "text/x-kotlin",
   "name": "kotlin",
   "nbconvert_exporter": "",
   "pygments_lexer": "kotlin",
   "version": "1.9.23"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
